package feedback.core.services.impl;

import java.util.List;

import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import feedback.core.models.entities.Faculty;
import feedback.core.repositories.EntityChangeRepo;
import feedback.core.services.FacultyServices;
@Service("fcsv")
public class FacultyServicesImpl extends EntityManagerServicesImpl implements FacultyServices {
	@Autowired
	private EntityChangeRepo repo;
	@Override
	public Faculty getByNo(String no) {
		List<Faculty> faculties =  (List<Faculty>) repo.findByCriteria(Faculty.class, Restrictions.eq("facultyNo", no));
		if(faculties.size()>0) return faculties.get(0);
		return new Faculty();
	}

	@Override
	public Faculty getByName(String name) {
		List<Faculty> faculties =  (List<Faculty>) repo.findByCriteria(Faculty.class, Restrictions.eq("facultyName", name));
		if(faculties.size()>0) return faculties.get(0);
		return new Faculty();
	}
	

}
